define(['jquery','mui','form','page', 'picker'], function($,$$,Form,Page,undefined) {
    var Controller = {
        index: function () {
        },
        bind: function () {
            Form.api.bindevent($("#login-form"));
        },
        login:function() {
            if(window.localStorage.data_account=='' || window.localStorage.data_account==undefined){
                Form.api.bindevent($("#login-form"), function (data, ret) {
                    setTimeout(function () {
                        if(data.account){
                            window.localStorage.data_account = data.account;
                            window.localStorage.data_pwd = data.pwd;
                        }
                        location.href = ret.url ? ret.url : "/";
                    }, 1000);
                });
            } else{
                showLoading(); // 显示加载框
                $.ajax({
                    type: "post",
                    url: "/wap/user/autologin",
                    data: { account: window.localStorage.data_account, password: window.localStorage.data_pwd},
                    success:function(res){
                        if(res.code==0){
                            window.localStorage.data_account = '';
                            window.localStorage.data_pwd = '';
                            mui.alert(res.msg);
                            mui.showLoading("不可操作.."); //加载文字和类型，plus环境中类型为div时强制以div方式显示
                        }else{
                            location.href = res.url;
                            return false;
                        }
                    }
                });
            }
        },
        logout: function () {
            alert('1111');
        },
        api: {
            bindevent: function () {
                Form.api.bindevent($("form[role=form]"));
            }
        }
    }
    return Controller;
})
